<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <style>
      .box{
        width: 100px;
        height: 100px;
        display: flex;
        justify-content:center;
        align-items:center;
      }
      .red{
        background-color: red;
      }
      .blue{
        background-color: blue;
      }
      .transition{
        /* linear 均速 */
        /* linear 均速 */
        transition: background-color 1s linear;
      }
    </style>
  </head>
  <body>
    <div id="app">
      
    </div>
    
    <script src="../js/vue.js"></script>

    <script>
      const app = Vue.createApp({
        data() {
          return {
            isRed:true,
            isBlue:false
          }
        },
        methods: {
          deal(){
            this.isRed = !this.isRed;
            this.isBlue = !this.isBlue;
          }
        },
        template:`
            <div>
              <div class="box transition" :class="{red:isRed, blue:isBlue}">2021年8月20日10:02:25</div>
              <button @click="deal">切换</button>
            </div>
        `
      }).mount("#app");
    </script>
  </body>
</html>